import axios from 'axios';
import axiosTauriApiAdapter from 'axios-tauri-api-adapter';

const instance = axios.create({
  baseURL: process.env.VUE_APP_DEV_BASE_API, 
  timeout: 5000, 
  //adapter: axiosTauriApiAdapter
});


export default {
  // 发送recognize请求
  sendRecognizeRequest(value,filename,carNum) {
    const requestData = {
        value: value,
        filename: filename,
        car_num:carNum
      };
    return instance.post('/recognize', requestData);
  },
  
  //发送获取进度请求
  sendGetProgress(filename) {
    return instance.get(`/progress/${filename}`);
  },

  //发送下载视频请求
  sendDownloadVideo(output_video){
    const encodedVideoPath = encodeURIComponent(output_video)
    return instance.get(`/download/${encodedVideoPath}`,{
       responseType: 'blob' // 指定响应数据类型为二进制
    })
  },

  //发送获取下载列表请求
  sendDownloadList(output_video){
    console.log("222")
    return instance.get(`/downlist/${output_video}`);
  }
}